home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
Error Dialogs
/
ErrorAlert.sit
/
ErrorCheck.h
< prev
next >
Wrap
Text File
|
1994-02-12
|
5KB
|
113 lines
//////////////////////////////////////////////////////////////////////
//
// ErrorCheck.h
//
// This is the header file for ErrorCheck.cp. Using this code it is possible
// to report a wide variety of messages to the user, and either display a
// simple Alert or a more sophisticated debugging alert.
//
// Related Files: ErrorCheck.rsrc contains the minimum number of resources to
// operate ErrorCheck. It also provides a list of standardized strings to
// output typical messages to the user.
//
/////////////////////////////////////////////////////////////////////
#ifndef ErrorCheck
#define ErrorCheck
// When the following #define is included, other modules are expected to implement
// additional error checking code that takes extra time, but stops bugs dead in
// their tracks. In addition, the program drops right into the local debugger
// using DebugStr, instead of bothering to put up a dialog box..... Among other
// things, this allows us to include special debugging strings in our code in a
// transparent and extendable way.
// When compiling final versions (or testing for performance) comment it out
#define SANITY_CHECK
// String constants used in ParamText
const Str255 kEmptyString = "\p";
// This one gets used if the program is unable to obtain a string from the STR#
// resource. Since this is hard coded, this is obviously a last ditch chance to
// put something up!
const Str255 kBogusError = "\pUnrecoverable Error";
// Error strings are combined into categories, each category being a separate
// STR# resource. This header creates a set of generic errors, usually used to flag
// conditions like older ROMs or System Software. Each major object, module, or
// subsection should define its own 'STR#' resource to handle errors it flags.
//
// NOTE: Some of these erros are very generic and should be overridden with a more
// specific error string whenever possible.
const short rDefaultStrings = 5000;
const short errOSErr = 1; // This one should probably never be used for a real error
const short errWimpyROMs = 2; // Used if ROMs are older than the 128K Mac Plus ROMs
const short errNeedSystem6 = 3;
const short errNeedSystem607 = 4;
const short errNeedSystem7 = 5;
const short errWeirdSystem = 6; // right minimum system, but missing something that
// should be there
const short errNoMBAR = 7;
const short errNoMENU = 8;
const short errNoCNTL = 9;
const short errNoWIND = 10;
// 'ALRT' constants (DITLs will have the same resource ID)
const short rDeathAlert = 5000; // Alert resource for program crash
const short rNotDeadYetAlert = 5001; // Alert resource for non-fatal error.
// Function Declarations
// In order to keep the interface flexible, I used overloaded functions. The first function
// definition is the one that most final program error routines should call -- one that grabs
// a string from a resource and displays it.
// The others are primarily intended for debugging, but are included even if compiled in
// the final version. They could be used when the program needs to present a customized
// string that it builds beforehand.
// All routines pass in a Boolean that tells whether or not this is a fatal eror.
extern void ErrorAlert (short ErrorStringsList,
short ErrorStringNumber,
Boolean DeadOnArrival);
// Allows the user to specify a specific string. Great if you need to build the string
// beforehand or if you just want to include a DebugStr. Okay, I guess you could just
// call DebugStr, but this way all errors have a consistent interface.
extern void ErrorAlert (Str255 ErrorMessage,
Boolean DeadOnArrival);
// This one combines a string and a short, useful for giving a numerical
// error code, such as an OSErr.
extern void ErrorAlert (Str255 ErrorMessage,
short ErrorNumber,
Boolean DeadOnArrival);
// This last one combines references to a string contained in the resource fork with
// a number. Usually, this is used to report OSErrs.
extern void ErrorAlert (short ErrorStringsList,
short ErrorStringNumber,
short ErrorNumber,
Boolean DeadOnArrival);
// These routines are used for simple sanity checking -- since they always call ErrorAlert
// without doing anything nice, they aren't suitable for robust error checking code that
// should exit gracefully. All of them return the actual error number returned by the
// system.
// MemoryErrCheck and ResourceErrCheck check for the additional case of a NIL pointer.
// Because MemoryErrCheck can be used on Ptrs or Handles, we use overloaded functions again.
extern void OSErrCheck (OSErr err);
extern void MemoryErrCheck (Handle err);
extern void MemoryErrCheck (Ptr err);
extern void ResourceErrCheck (Handle err);
#endif ErrorCheck